package com.smallcc.dataobject.mapper;

import com.smallcc.dataobject.ProductCategory;
import com.smallcc.vo.ProductInfoVO;
import org.apache.ibatis.annotations.*;

import javax.validation.constraints.Min;
import java.util.List;
import java.util.Map;

/**
 * @author 晓风过境
 * @TODO
 * @date 2018/4/4 14:04
 * @day 04
 * @return $text$
 * @title ${CLASS_NAME}
 * @project_name sell
 */
@Mapper
public interface ProductCategoryMapper {
    @Insert("insert into product_category(category_name,category_type) value(#{category_name,jdbcType=VARCHAR},#{category_type,jdbcType=INTEGER})")
    int insertByMap(Map<String,Object> map);
    @Insert("insert into product_category(category_name,category_type) value(#{categoryName,jdbcType=VARCHAR},#{categoryType,jdbcType=INTEGER})")
    int insertByObject(ProductCategory productCategory);

    @Select("select * from product_category where category_type=#{categroyType}")
    @Results({
            @Result(column = "category_id",property = "categoryId"),
            @Result(column = "category_type",property = "categoryType"),
            @Result(column = "category_name",property = "categoryName")
    })
    ProductCategory findByCategoryType(Integer categroyType);
    @Select("select * from product_category where category_name=#{categoryName}")
    @Results({
            @Result(column = "category_id",property = "categoryId"),
            @Result(column = "category_type",property = "categoryType"),
            @Result(column = "category_name",property = "categoryName")
    })
    List<ProductCategory> findByCategoryName(String categoryName);
    @Update("update product_category set category_name =#{categoryName} where category_type=#{categoryType}")
    int updateByCategoryType(@Param("categoryName") String categoryName, @Param("categoryType") Integer categoryType);
    @Update("update product_category set category_name =#{categoryName} where category_type=#{categoryType}")
    int updateByCategoryObject(ProductCategory productCategory);
    @Delete("delete from product_category where category_type=#{categoryType}")
    int deleteByCategoryType(Integer categoryType);

    ProductCategory selectByCategoryType(Integer categoryType);
}
